#ifndef LONGKEY_COMMON_MODULE_UTILS_H_
#define LONGKEY_COMMON_MODULE_UTILS_H_

#include "string.h"

// Utilities for working with modules in processes.

// Returns the module handle of a module, given a pointer to a static
// member of the module (e.g. a static function or static variable).
HMODULE ModuleFromStatic(void* pointer_to_static_in_module);

// Copies the path of the directory that contains the file for 'module' into
// 'directory'.
//
// @param module Must be a valid, non-NULL module handle.
// @param directory MUST have room for MAX_PATH characters or more.  The path
// copied into this buffer will not have a trailing backslash.
//
// @return false iff there is an error.
bool GetModuleDirectory(HMODULE module, TCHAR* directory);

/**
* Returns a path to a module.  Uses the
* Win32 GetModuleFileName function, so you
* can pass NULL for module.
*
* @param module Handle to the module or NULL for the current module.
* @param path Holds the path to the module on successful return.
* @returns S_OK if successful, otherwise an error value.
*/
HRESULT GetModuleFileName(HMODULE module, OUT CString* path);

#endif	// LONGKEY_COMMON_MODULE_UTILS_H_